<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>订单详情</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <!-- <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/sixPwd.css"/> -->
    <style>
        body {
            font-size: 14px;
            scroll:no;
        }

        footer.aui-nav {
            z-index: 99999;
        }

        header.aui-bar {
            background: #fff;
            position: fixed;
        }

        .aui-title {
            color: #000;
        }

        .aui-nav .aui-bar-tab .active .aui-iconfont, .aui-nav .aui-bar-tab .active p {
            color: #327afa !important;
        }

        .active {
            color: #327afa !important;
        }

        .aui-tab-nav li.active {
            color: #327afa;
            border-bottom: 2px #327afa solid;
        }

        .aui-bar .aui-iconfont {
            color: #000;
        }

        .zfBlue {
            text-align: left !important;
            padding-left: 15px;
            font-size: 12px;
        }

        footer > div {
            text-align: center;
            line-height: 55px;
            position: relative;
        }

        footer > div > div:nth-of-type(1) {
            border-right: 1px solid #d9d9d9;
        }

        footer > div > div:nth-of-type(1) a {
            display: block;
            width: 100%;
            height: 100%;
            color: #000;
        }

        footer > div > div:nth-of-type(2) {
            color: #327afa;
        }

        footer > div > div:nth-of-type(3) {
            background: #327afa;
            color: #fff;
        }

        .mui-popover {
            width: 100px;
        }

        .moreList li {
            padding: 5px 8px;
            width: 100px;
            text-align: center;
        }

        .contain {
            margin-top: 105px;
            margin-bottom: 55px;
        }

        .haderTitle li > span {
            float: left;
            display: block;
        }

        .contain .aui-tab-nav li {
            line-height: inherit;
            height: auto;
            position: relative;
            padding: 15px;
            width: 100%;
        }

        .contain .aui-tab-nav {
            height: inherit;
            display: block;
        }

        .contents {
            margin-left: 25px;
            margin-right: 15px;
            text-align: left;
            font-size: 14px;
            color:#666;
        }

        .content {
            display: inline-block;
        }

        .contents > span {
            display: block;
        }

        .time {
            display: block;
        }

        .icon {
            position: absolute;
            top: 50%;
            text-align: center;
            -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
        }

        .address {
            margin-top: 8px;
        }

        .good {
            background: #fff;
            margin-top: 15px;
            margin-bottom: 15px;
        }

        .good-pirce {
            color: #ff0005;
            font-weight: bold;
        }

        .good-info-list {
            color: #a3a3a3;
            font-size: 12px;
            line-height: 1.4;
        }

        .company-name {
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            background: #fff;
            padding-left: 15px;
            position: relative;
        }

        .status {
            width: 100%;
            text-align: right;
            float: left;
            margin-top: 5px;
        }

        .status span {
            display: block;
            padding: 2px 12px;
            /*background: #d9d9d9;*/
            background: #ccc;
            border-radius: 3px;
            color: #fff;
        }

        .good_bottom {
            padding: 15px;
        }

        .good_bottom ul li {
            overflow: hidden;
            margin-bottom: 5px;
        }

        .good_bottom ul li span {
            display: block;
        }

        .shiji {
            font-weight: bold;
            font-size: 18px;
        }

        .good-info .aui-list-view {
            margin: 0;
        }

        .contact {
            overflow: hidden;
        }

        .contactMeg, .contactPhone {
            display: block;
            padding: 5px 10px;
            /*border: 1px solid #327afa;*/
            text-align: center;
            float: left;
            width: 47%;
            margin-top: 10px;
            border-radius: 3px;
        }

        .contactMeg {
            margin-right: 2%;
        }

        .menuRgiht {
            float: right;
            margin-right: 20px;
        }

        .good_bottom {
            background: #fff;
        }

        .aui-iconfont {
            margin-right: 5px;
        }

        .total {
            margin-top: 15px;
            margin-bottom: 10px;
        }

        .total .good-pirce {
            font-size: 18px;
        }

        .waitingTips {
            width: 100%;
            background: #ffd9cd;
            text-align: center;
            height: 25px;
            line-height: 25px;
            overflow: hidden;
            color: #ff6868;
            font-size: 12px;
        }

        /*下面弹出的样式*/
        .pickerToTop {
            position: fixed;
            bottom: 0;
            -webkit-transform: translateY(195px);
            height: 195px;
            overflow-y: auto;
            -webkit-transition: .5s;
            transition: .5s;
            z-index: 999;
            width: 100%;
            text-align: center;
        }

        .toTopAnimate {
            -webkit-transform: translateY(00px);
        }

        .myBorder {
            height: 8px;
            background: #797979;
        }

        .paw {
            background: url(../../image/pawbg.jpg);
            background-size: contain;
            margin: 0 auto;
            width: 270px !important;
            letter-spacing: 40px;
        }

        .aui-icon-roundclose {
            position: absolute;
            right: 10px;
            top: 10px;
            font-size: 20px;
            color: #000;
            z-index: 9;
        }

        .pickerToTop .aui-list-view-cell:after {
            border: 0;
        }

        .grayColor{
            color:#666;
        }
        .whiteColor{
            color:#fff !important;
        }
        .finish .btn{
            color:#666 !important;
            background: #fff;
            font-size: 15px;
        }
        .finish .btn.blue{
            background: #327afa;
            color: #fff !important;
        }
    </style>
</head>
<body>
<div id="orderInfo-content">
    <!--订单详情-->
</div>
<script id="orderInfo-template" type="text/x-dot-template">
    <header class="aui-bar aui-bar-nav aui-border-b">
        <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeWin()"></div>
        <div class="aui-title">
            订单详情
        </div>
        {{?it.status==3}}<div class="waiting waitingTips">剩余收货时间：12天09小时</div>{{?}}
        <ul class="aui-tab-nav aui-border-t haderTitle">
            <li class="zfBlue aui-arrow-right" style="font-size: 14px;color: #666 !important;">
                {{? it.status == 0}}交易关闭
                {{?? it.status == 1}}等待买家付款
                {{?? it.status == 2}}买家已付款
                {{?? it.status == 3}}卖家已发货
                {{?? it.status == 4}}交易成功
                {{?? it.status == 5}}已评价
                {{?? it.status == 6}}申请退款
                {{?? it.status == 7}}申请退货
                {{?}}
            </li>
        </ul>
    </header>

    <div class="contain">

        {{? it.status > 0}}
        <ul class="aui-tab-nav aui-border-t haderTitle">
            {{? it.status > 3}}
            <li class="aui-arrow-right aui-border-b">
                <span class="aui-iconfont aui-icon-deliver icon"></span>
                <div class="contents">
                    <div class="content">已签收，签收人凭取货码签收。感谢使用圆通速递，期待再次为您服务。</div>
                    <span class="time">2016-08-12  20:12:35</span>
                </div>
            </li>
            {{?}}
            <li class="">
                <span class="aui-iconfont aui-icon-location icon"></span>

                <div class="contents">
                    <span class="name aui-pull-left">收货人：{{=it.buyer_name}}</span>
                    <span class="phone aui-pull-right">{{=it.buyer_mobile}}</span>

                    <div class="content address">收货地址：{{=it.buyer_address}}</div>
                </div>
            </li>
        </ul>
        {{?}}
        <div class="good">
            <div class="good-info">
                <div class="company-name aui-arrow-right" onclick="go2Shop({{=it.company.userid}},'../')">
                    <label class="name comName">{{=it.company.company}}</label>
                </div>
                <ul class="aui-list-view">
                    {{ for (var i in it.goods) { }}
                    <li class="aui-list-view-cell aui-img aui-counter-list">
                        <img class="aui-img-object aui-pull-left" src="{{=it.goods[i].thumb}}">

                        <div class="aui-img-body">
                            <span class="good-name aui-ellipsis-2">{{=it.goods[i].title}}</span>

                            <div class="good-info-lists">
                                <div class="good-info-list aui-ellipsis-2">{{=it.goods[i].note}}</div>
                                <div class=" aui-pull-left good-pirce" style="font-weight: normal !important;">￥{{=it.goods[i].amount}}</div>
                                <div class=" aui-pull-right grayColor">x<span class="good-count">{{=it.goods[i].number}}</span>
                                </div>
                                <div class="status "><span class="aui-pull-right">
                                    {{? it.status == 0}}交易关闭
                                    {{?? it.status == 1}}等待买家付款
                                    {{?? it.status == 2}}买家已付款
                                    {{?? it.status == 3}}卖家已发货
                                    {{?? it.status == 4}}交易成功
                                    {{?? it.status == 5}}已评价
                                    {{?? it.status == 6}}申请退款
                                    {{?? it.status == 7}}申请退货
                                    {{?}}
                                </span></div>
                            </div>
                        </div>
                    </li>
                    {{ } }}
                </ul>
                <div class="good_bottom">
                    <ul>
                        <li>
                            <span class="aui-pull-left grayColor">店铺优惠</span>
                            <span class="aui-pull-right">￥0.00</span>
                        </li>
                        <li>
                            <span class="aui-pull-left grayColor">货品总价</span>
                            <span class="aui-pull-right">￥{{=it.goods_amount}}</span>
                        </li>
                        <li>
                            <span class="aui-pull-left grayColor">运费</span>
                            <span class="aui-pull-right">￥{{=it.fee}}</span>
                        </li>
                        <li>
                            <span class="aui-pull-left shiji grayColor" style="font-weight: normal !important;">实付款</span>
                            <span class="aui-pull-right good-pirce" style="font-size: 18px;font-weight: normal !important;">￥{{=it.order_amount}}</span>
                        </li>
                    </ul>
                    <div class="contact aui-clearfix">
                        <span class="contactMeg aui-bg-info whiteColor aui-pull-left" tapmode onclick="openchat({{=it.company.userid}},'{{=it.company.thumb}}','{{=it.company.company}}','../',1);"><i class="aui-iconfont aui-icon-message whiteColor"></i>联系卖家</span>
                        <span class="contactPhone aui-bg-primary aui-pull-right"><i class="aui-iconfont aui-icon-phone whiteColor"></i><a class="whiteColor" href="tel:{{=it.company.telephone}}">拨打电话</a></span>
                    </div>
                </div>
            </div>
        </div>
        <ul class="aui-list-view">
            <li class="aui-list-view-cell" data-type="proType" tapmode onclick="">
                <a>
                    <span class="grayColor">支付方式</span>
                    <span class="menuRgiht tixianType">支付宝</span>
                </a>
            </li>
        </ul>
        <div class="good_bottom">
            <ul>
                <li>
                    <span class="aui-pull-left grayColor">订单号</span>
                    <span class="aui-pull-right">{{=it.order_sn}}</span>
                </li>
                <li>
                    <span class="aui-pull-left grayColor">下单时间</span>
                    <span class="aui-pull-right">{{=it.addtime}}</span>
                </li>
                {{? it.status >= 2}}
                <li>
                    <span class="aui-pull-left grayColor">付款时间</span>
                    <span class="aui-pull-right">{{it.paytime}}</span>
                </li>
                {{?}}
                {{? it.status >= 3}}
                <li>
                    <span class="aui-pull-left grayColor">发货时间</span>
                    <span class="aui-pull-right">{{=it.paytime}}</span>
                </li>
                {{?}}
            </ul>
        </div>
        <ul class="aui-list-view total">
            <li class="aui-list-view-cell" data-type="proType" >
                <a class="">
                    应付款（含运费￥{{? it.status == 1}}{{=it.fee}}{{??}}0.00{{?}}）
                    <span class="menuRgiht good-pirce">￥{{=it.payable_amount}}</span>
                </a>
            </li>
        </ul>
    </div>
    <footer class="aui-nav" id="aui-footer">
        <!-- 交易关闭 -->
        {{? it.status == 0}}
        <div class="finish">
            <div class="myBtn" tapmode onclick="deleteOrder('{{=it.order_id}}')" >删除订单</div>
        </div>

        {{?? it.status == 1}}
        <div class="finish">
            <div class="aui-col-xs-6 aui-border-t btn" tapmode onclick="cancellationOrder('{{=it.order_id}}')">取消订单</div>
            <div class="aui-col-xs-6 aui-border-t btn blue" tapmode onclick="goToPay()">付款</div>
        </div>

        {{?? it.status == 2}}
        <div class="myBtn" tapmode onclick="remind('{{=it.order_id}}')">提醒发货</div>


        {{?? it.status == 3}}
        <div class="finish">
            <div class="aui-col-xs-6 aui-border-t btn">延长收货时间</div>
            <div class="aui-col-xs-6 aui-border-t btn blue" tapmode onclick="confirmReceipt('{{=it.order_id}}')">确定收货</div>
        </div>

        {{?? it.status == 4}}
         <div class="finish">
             <!--<div class="aui-col-xs-2 aui-border-t"><a href="#waiting">更多</a></div>-->
             <div class="aui-col-xs-6 aui-border-t" tapmode onclick="openchat({{=it.company.userid}},'{{=it.company.thumb}}','{{=it.company.company}}','../',1);">申请售后</div>
             <div class="aui-col-xs-6 aui-border-t blue" tapmode onclick="goToEvaluate('{{=it.order_id}}')">评价</div>
        </div>

        <!--{{?? it.status == 5}}-->
        <!--<div class="finish">-->
            <!--<div class="aui-col-xs-12 aui-border-t btn" tapmode onclick="openToTwo('/root/proComments_win')">修改评价</div>-->
        <!--</div>-->
        {{?}}
    </footer>

</script>


</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../../script/mui.js"></script>
<script type="text/javascript" src="../../script/sixPwd.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript">
    var orderId,totalMoney,showPayPage,orderNo;
    apiready = function () {

        api.parseTapmode();
        orderId = api.pageParam.orderId;
        showPayPage= api.pageParam.showPayPage;
        getStorageAll();
        getOrderInfo(orderId);

    }

    function getOrderInfo(orderId) {
        showLoading();
        var data = {
            orderId: orderId,
            userName: user_name,
        };
        var url = 'User/orderInfoUser';
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                var content = $api.byId('orderInfo-content');
                var tpl = $api.byId('orderInfo-template').text;
                totalMoney=ret.msg.payable_amount
                var tempFn = doT.template(tpl);
                orderNo=ret.msg.order_sn;
                $api.html(content, '');
                $api.html(content, tempFn(ret.msg));

                var header = $api.dom('header');
                $api.fixIos7Bar(header);
                hideLoading();
                //判断是否是单击了付款按钮进来
                if(showPayPage){
                    goToPay();
                }
            } else {
                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'bottom'
                });
                failClose();
            }
        });
    }
    //去评价
    function goToEvaluate(orderId) {
        var orderId = orderId;
        var companyName = $(".comName").text();
        api.openWin({
            name: "evaluate",
            url: "../proEvaluate_win.html",
            vScrollBarEnabled : false,
            hScrollBarEnabled : false,
            pageParam: {
                orderId: orderId,
                companyName: companyName
            }
        })
    }

    //为了在下面的热门类别可以通用，单独出来
    function changeCheck(obj) {
        $(obj).parent().find("li").removeClass("active");
        $(obj).addClass("active");
        var type = $(obj).attr("data-type");
        api.execScript({
            frameName: "wallet_frm",
            script: "changeContent('" + type + "')"
        })
    }
    //确认收货
    function confirmReceipt(orderId) {
        api.openFrame({
            bgColor: 'rgba(0,0,0,0.6)',
            name: 'passWord',
            url: 'passWord.html',
            bounces: false,
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                orderId: orderId
            }
        });
    }
    //取消订单
    function cancellationOrder(orderId) {
        if (confirm('确定取消吗')) {
            //订单关闭
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
            };
            url = "User/cancellationOrder";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    api.toast({
                        msg: '修改订单成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    updateOrderNum();
                    getOrderInfo(orderId);
                } else {
                    api.toast({
                        msg: '修改订单失败',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }

    //删除订单
    function deleteOrder(orderId) {
        if (confirm('确定删除吗')) {
            //订单关闭
            showLoading();
            data = {
                userName: user_name,
                orderId: orderId,
            };
            url = "User/deleteOrder";
            ajaxRequest(url, 'post', data, function (ret, err) {
                if (ret.status == 1) {
                    api.toast({
                        msg: '删除订单成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    updateOrderNum();
//                    $("#order" + orderId).hide();
                    openToTwo("buyerOrderList_win")
                } else {
                    api.toast({
                        msg: '删除订单失败',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
            hideLoading();
        }
    }




    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    function hidePopover() {
        mui('.mui-popover').popover('hide');
    }
    $(document).on("touchstart", "body", function () {
        mui('.mui-popover').popover('hide');
    })
    // mui遮罩
    var mask = mui.createMask(hidePicker);
    // 显示遮罩
    function showPicker(obj) {
        mask.show();
        $(".pickerToTop").addClass("toTopAnimate");
    }
    // 关闭遮罩
    function hidePicker() {
        $(".pickerToTop").removeClass("toTopAnimate");
        mask.myclose();
    }
    boxInput.init(function () {
        var result = boxInput.getBoxInputValue();
        alert(result)
    })
    //支付方法
    function goToPay() {
        api.openFrame({
            bgColor : 'rgba(0,0,0,0)',
            name : 'payPage_frm',
            url : 'payPage_frm.html',
            bounces : false,
            rect : {
                x : 0,
                y : 0,
                w : 'auto',
                h : 'auto'
            },
            pageParam:{
                money:totalMoney,
                orderId:orderId,
                orderNo:orderNo
            }
        });
    }
</script>
</html>
